<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>垃圾分类知识库</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <h1>垃圾处理小贴士</h1>
        <div class="search-box">
            <input type="text" id="tipSearch" placeholder="输入垃圾名称查询处理建议">
            <button onclick="searchTips()">搜索</button>
        </div>
        <div id="results">
            <div class="common-tips">
                <h2>常见处理指南</h2>
                <ul id="commonTipsList"></ul>
            </div>
            <div class="search-results" style="display:none;">
                <h2>查询结果</h2>
                <div id="tipDetails"></div>
            </div>
        </div>
    </div>
    <script>
        // 初始化常见提示
        window.onload = function() {
            fetch('/tips?q=常见')
                .then(res => res.json())
                .then(data => {
                    const list = document.getElementById('commonTipsList');
                    data.forEach(item => {
                        list.innerHTML += `<li>
                            <strong>${item.name}</strong> (${item.category})
                            <p>${item.handling_tips}</p>
                        </li>`;
                    });
                });
        };

        function searchTips() {
            const keyword = document.getElementById('tipSearch').value;
            fetch(`/tips?q=${encodeURIComponent(keyword)}`)
                .then(res => res.json())
                .then(data => {
                    const details = document.getElementById('tipDetails');
                    details.innerHTML = data.length ? 
                        data.map(item => `
                            <div class="tip-item">
                                <h3>${item.name}</h3>
                                <p><strong>分类：</strong>${item.category}</p>
                                <p><strong>处理建议：</strong>${item.handling_tips}</p>
                            </div>
                        `).join('') : 
                        '<p>未找到相关处理建议</p>';
                    
                    document.querySelector('.common-tips').style.display = 'none';
                    document.querySelector('.search-results').style.display = 'block';
                });
        }
    </script>
</body>
</html>

<div class="two-column-layout">
    <div class="classification-standard">
        <h2>四大分类标准</h2>
        <div class="category-card recyclable">
            <h3>可回收物</h3>
            <ul>
                <li>废纸张</li>
                <li>废塑料</li>
                <li>废玻璃</li>
                <li>废金属</li>
            </ul>
        </div>
        <!-- 其他分类卡片类似结构 -->
    </div>
    
    <div class="handling-steps">
        <h2>标准处理流程</h2>
        <ol class="step-list">
            <li>去除残留液体</li>
            <li>清洁污染表面</li>
            <li>压减物品体积</li>
            <li>正确分类投放</li>
        </ol>
    </div>
</div>

<style>
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.category-card {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.recyclable { background: #e3f2fd; }

.step-list {
    counter-reset: step;
    padding-left: 2rem;
}
</style>